package com.wfit.controller.admin;

import com.wfit.result.Result;
import com.wfit.service.UploadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@Api(tags = "图片上传")
@RestController
@RequestMapping("/upload")
@RequiredArgsConstructor
public class UploadImageController {
    @Autowired
    private UploadService uploadService;

    @ApiOperation("图片上传")
    @PostMapping
    public Result addORupdateCommodity( MultipartFile image) throws IOException {

        return Result.success(image);
    }

    @ApiOperation("头像更新")
    @PostMapping("/avatar")
    public Result updateUserAvatar( MultipartFile image) throws IOException {

        uploadService.uploadAvatar(image);
        return Result.success();
    }
}
